package com.steven.concurrent.exception;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class CaptureUncaughtException {
	public static void main(String[] args) {
		//Thread.setDefaultUncaughtExceptionHandler(new MyUncaughtExceptionHandler());
		ExecutorService exec = Executors.newCachedThreadPool(new HandlerThreadFactory());	// 构建通用的异常处理线程
		exec.execute(new ExceptionThread());  // ExceptionThread中抛出异常
		exec.shutdown();
	}
	/* Output:
	concurrent.exception.HandlerThreadFactory@12d34a6 creating new Thread
	created Thread[Thread-0,5,main]
	eh = concurrent.exception.MyUncaughtExceptionHandler@557d7e
	run() by Thread[Thread-0,5,main]
	eh = concurrent.exception.MyUncaughtExceptionHandler@557d7e
	caught java.lang.RuntimeException*/
}
